package descentFly.app.managePanel.chat
{
	import UIFree.uif_component;
	
	public class df_userList extends df_turnList
	{
		public function df_userList(parent:uif_component, ax:int=0, ay:int=0, awidth:int=0, aheight:int=0, styleClass:String='list')
		{
			super(parent, ax, ay, awidth, aheight, styleClass);
		}
		
		public function addUser(uid: String): void {
			var item: df_chatItem = findItemFromUID(uid);
			if (!item) {
				social.getUserFromObj(uid, function(user: Object): void {
					new df_chatItem(scrollArea, user, '', 'chatItem');
				});
			}
		}
		
		public function findItemFromUID(uid: String): df_chatItem {
			for (var i: int=0; i<scrollArea.numChildren; i++) {
				var item: df_chatItem = scrollArea.getChildAt(i) as df_chatItem;
				if (item._data.uid == uid) return item;
			}
			return null;
		}
		
		public function removeUser(uid: String): void {
			var item: df_chatItem = findItemFromUID(uid);
			if (item) item.dispose();
		}		
	}
}